import request from '@/sheep/request';

const ShortDramaUtil = {
  // 获取短剧列表
  getShortDramaList: (dramaName) => {
    return request({
      url: '/member/short-drama/list',
      method: 'GET',
      params: {
        dramaName: dramaName || undefined,
      },
      custom: {
        showLoading: false, // 不显示加载动画
        showError: true,    // 显示错误信息
        auth: false,        // 不需要授权
      },
    });
  },

  // 获取短剧信息
  getShortDramaInfo: (dramaId) => {
    return request({
      url: '/member/short-drama/get',
      method: 'GET',
      params: {
        id: dramaId
      },
      custom: {
        showLoading: true,
        showError: true,
        auth: true,
      },
    });
  },

  // 获取短剧剧集详情
  getShortDramaEpisodes: (dramaId) => {
    return request({
      url: '/member/short-drama/episodes',
      method: 'GET',
      params: {
        dramaId
      },
      custom: {
        showLoading: true,  // 显示加载动画
        showError: true,    // 显示错误信息
        auth: false,        // 暂时不需要授权，用于测试
      },
    });
  },

  // 获取剧集评论列表
  getEpisodeCommentList: (episodeId) => {
    return request({
      url: '/app/drama-episode-comment/list-by-episode',
      method: 'GET',
      params: {
        episodeId
      },
      custom: {
        showLoading: false,
        showError: true,
        auth: false,
      },
    });
  },

  // 创建剧集评论
  createEpisodeComment: (params) => {
    return request({
      url: '/app/drama-episode-comment/create',
      method: 'POST',
      data: params,
      custom: {
        auth: true,
        showLoading: true,
        showSuccess: true,
        successMsg: '评论成功',
      },
    });
  },

  // 删除剧集评论
  deleteEpisodeComment: (params) => {
    return request({
      url: '/app/drama-episode-comment/delete',
      method: 'DELETE',
      data: params,
      custom: {
        auth: true,
        showLoading: true,
        showSuccess: true,
        successMsg: '删除成功',
      },
    });
  },

  // 添加剧集点赞
  createLike: (episodeId) => {
    return request({
      url: '/app/drama-episode-like/create',
      method: 'POST',
      data: {
        episodeId: episodeId,
      },
      custom: {
        auth: true,
        showSuccess: true,
        successMsg: '点赞成功',
      },
    });
  },

  // 取消剧集点赞
  cancelLike: (episodeId) => {
    return request({
      url: '/app/drama-episode-like/cancel',
      method: 'DELETE',
      data: {
        episodeId: episodeId,
      },
      custom: {
        auth: true,
        showSuccess: true,
        successMsg: '取消点赞成功',
      },
    });
  },

  // 检查是否已点赞剧集
  checkLike: (episodeId) => {
    return request({
      url: '/app/drama-episode-like/check',
      method: 'GET',
      params: {
        episodeId: episodeId,
      },
      custom: {
        auth: true,
        showLoading: false,
        showError: false,
      },
    });
  },

  // 添加剧集收藏
  createFavorite: (episodeId) => {
    return request({
      url: '/app/drama-episode-favorite/create',
      method: 'POST',
      data: {
        episodeId: episodeId,
      },
      custom: {
        auth: true,
        showSuccess: true,
        successMsg: '收藏成功',
      },
    });
  },

  // 取消剧集收藏
  cancelFavorite: (episodeId) => {
    return request({
      url: '/app/drama-episode-favorite/cancel',
      method: 'DELETE',
      data: {
        episodeId: episodeId,
      },
      custom: {
        auth: true,
        showSuccess: true,
        successMsg: '取消收藏成功',
      },
    });
  },

  // 检查是否已收藏剧集
  checkFavorite: (episodeId) => {
    return request({
      url: '/app/drama-episode-favorite/check',
      method: 'GET',
      params: {
        episodeId: episodeId,
      },
      custom: {
        auth: true,
        showLoading: false,
        showError: false,
      },
    });
  },

  // 创建解锁支付订单
  createUnlockOrder: (params) => {
    return request({
      url: '/member/short-drama/create-unlock-order',
      method: 'POST',
      data: params,
      custom: {
        auth: true,
        showLoading: true,
        showError: true,
      },
    });
  },
};

export default ShortDramaUtil;